{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "#导入必要的工具包\n",
    "import pandas as pd\n",
    "import numpy as np\n",
    "from sklearn.cluster import MiniBatchKMeans\n",
    "from sklearn import metrics\n",
    "import scipy.io as sio\n",
    "\n",
    "import matplotlib.pyplot as plt\n",
    "%matplotlib inline"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [],
   "source": [
    "eventContMaxtrix = sio.mmread(\"EV_eventContMatrix\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 16,
   "metadata": {},
   "outputs": [],
   "source": [
    "# 一个参数点（聚类数据为K）的模型，在校验集上评价聚类算法性能\n",
    "def K_cluster_analysis(K, df):\n",
    "    print(\"K-means begin with clusters: {}\".format(K))\n",
    "    \n",
    "    #K-means,在训练集上训练\n",
    "    km = MiniBatchKMeans(n_clusters = K)\n",
    "    km.fit(df)\n",
    "    \n",
    "    # 保存预测结果\n",
    "    cluster_result = km.predict(df)\n",
    "\n",
    "    # K值的评估标准\n",
    "    #常见的方法有轮廓系数Silhouette Coefficient和Calinski-Harabasz Index\n",
    "    #这两个分数值越大则聚类效果越好\n",
    "    #CH_score = metrics.calinski_harabaz_score(X_train,mb_kmeans.predict(X_train))\n",
    "    CH_score = metrics.silhouette_score(df,cluster_result)\n",
    "    print(\"CH_score: {}\".format(CH_score))\n",
    "    \n",
    "    return CH_score"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 17,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "K-means begin with clusters: 10\n",
      "CH_score: 0.3206876622681394\n",
      "K-means begin with clusters: 20\n",
      "CH_score: 0.007860249090913035\n",
      "K-means begin with clusters: 30\n",
      "CH_score: -0.15368943712646538\n",
      "K-means begin with clusters: 40\n",
      "CH_score: -0.02749508325319264\n",
      "K-means begin with clusters: 50\n",
      "CH_score: -0.16647512014905427\n",
      "K-means begin with clusters: 60\n",
      "CH_score: -0.036490558584285314\n",
      "K-means begin with clusters: 70\n",
      "CH_score: -0.09218421763461654\n",
      "K-means begin with clusters: 80\n",
      "CH_score: -0.079376911164118\n",
      "K-means begin with clusters: 90\n",
      "CH_score: -0.09109420825543521\n",
      "K-means begin with clusters: 100\n",
      "CH_score: -0.0782516551081194\n"
     ]
    }
   ],
   "source": [
    "# 设置超参数（聚类数目K）搜索范围\n",
    "Ks = [10,20,30,40,50,60,70,80,90,100]\n",
    "CH_scores = []\n",
    "for K in Ks:\n",
    "    ch = K_cluster_analysis(K, eventContMaxtrix)\n",
    "    CH_scores.append(ch)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 18,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "[<matplotlib.lines.Line2D at 0xac8eb38>]"
      ]
     },
     "execution_count": 18,
     "metadata": {},
     "output_type": "execute_result"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAX8AAAD8CAYAAACfF6SlAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAHz5JREFUeJzt3XuUFNW5/vHvC6iAIgiMxgCKKGiIRtGJh4h4o8ejJ1FycmKiyyTES4iK8ZaYkBsqao4oMcajaBRBPecXL0k0IVkqEcS7oIOigoASVBi5ZAIiiHKd/fvj7V70DD3MMF3d1d31fNZizXRP0bUpap6q2nvXWxZCQEREkqVd3A0QEZHiU/iLiCSQwl9EJIEU/iIiCaTwFxFJIIW/iEgCKfxFRBJI4S8ikkAKfxGRBOoQdwOa07Nnz9C3b9+4myEiUlZmz579rxBCVUvLlWz49+3bl9ra2ribISJSVszs/dYsp24fEZEEUviLiCSQwl9EJIEU/iIiCaTwFxFJIIW/iEgCKfxFRBKo4sJ/1SoYOxZeey3uloi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UhhLVxtycOZvYV4J8hhNnZb+dYNClTzToARwJ3hBAGAetJSBdPLum+7OHAAcBngd3xro2mkrJ/tKQgvzsK/wiZ2S548P+/EMIj6bdXZi7R0l//GVf7imgIcLqZvQc8iF/O34JfrnZIL9MbWBZP84quDqgLIcxKv/4jfjBI4r4BkALeDSHUhxA2A48Ax5Dc/SOjuf2hDuiTtVwk20bhH5F0n/Y9wPwQws1ZP5oCjEh/PwL4S7HbVmwhhJ+GEHqHEPriA3lPhRDOBmYAX08vlohtARBCWAEsNbOD028NA94igftG2hJgsJl1Tv/eZLZHIvePLM3tD1OA76Rn/QwGPsp0D+VDN3lFxMyOBZ4D3mRbP/fP8H7/h4H98J3+jBBC04GeimVmJwA/CiF8xcz64VcC3YHXgG+FEDbG2b5iMbMj8MHvXYHFwDn4yVci9w0zuwb4Jj5L7jXgfLwfOxH7h5k9AJyAV+9cCVwF/Jkc+0P6AHkbPjvoE+CcEEJt3m1Q+IuIJI+6fUREEkjhLyKSQAp/EZEEUviLiCSQwl9EJIEU/iIiCaTwFxFJIIW/iEgC/X91R0vd3b05IAAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    }
   ],
   "source": [
    "# 绘制不同PCA维数下模型的性能，找到最佳模型／参数（分数最高）\n",
    "plt.plot(Ks, np.array(CH_scores), 'b-')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
